// pages/balance.js
const customRequst = require('../../common/customRequst');
Page({
  /**
   * 页面的初始数据
   */
  data: {
    activeIndex: 0, //默认选中第一个
    numArray: [1, 20, 50, 80, 100, 200, ],
    payment: 1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  //切换金额
  activethis: function (event) { //点击选中事件
    console.log(event.currentTarget.dataset.item)
    let thisindex = event.currentTarget.dataset.thisindex; //当前index
    this.setData({
      activeIndex: thisindex,
      payment: event.currentTarget.dataset.item
    })
  },

  //创建支付订单
  goPay() {
    let that = this;
    customRequst.postRequest('api/accountbalance/recharge_order', {
      money: that.data.payment,
    }).then(res => {
      if(res.code == 1){
        let orderId = res.data.id;
        let url = '/pages/order/pay/index?id='+orderId;
        wx.navigateTo({
          url: url,
        })
      }else{
        wx.showToast({
          title: res,msg,
          icon:'none'
        });
      }
    })
  },
})